package cn.terminus.data.customer.custombusiness.impl;

import java.util.Date;

import cn.terminus.common.customer.bean.custombusiness.dto.CustomBusinessNewDto;
import cn.terminus.common.customer.bean.custombusiness.dto.CustomBusinessEditDto;
import cn.terminus.common.customer.bean.custombusiness.dto.CustomBusinessQueryDto;
import cn.terminus.common.customer.bean.custombusiness.dto.CustomBusinessDeleteDto;
import cn.terminus.common.customer.bean.custombusiness.dto.CustomBusinessGetsDto;
import cn.terminus.common.customer.bean.custombusiness.dto.CustomBusinessResultDto;
import cn.terminus.data.customer.custombusiness.dao.CustomBusinessDao;
import cn.terminus.data.customer.custombusiness.mapper.CustomBusinessMapper;
import org.springframework.stereotype.Repository;
import cn.terminus.result.common.result.TerminusResult;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import javax.annotation.Resource;

import java.util.List;

/**
 * (CustomBusiness)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:38
 */
@Repository
public class CustomBusinessDaoImpl implements CustomBusinessDao {
    @Resource
    private CustomBusinessMapper customBusinessMapper;

    @Override
    public Integer add(CustomBusinessNewDto dto) {
        return customBusinessMapper.add(dto);
    }

    @Override
    public Integer update(CustomBusinessEditDto dto) {
        return customBusinessMapper.update(dto);
    }

    @Override
    public List<CustomBusinessResultDto> gets(CustomBusinessGetsDto dto) {
        return customBusinessMapper.gets(dto);
    }

    @Override
    public List<CustomBusinessResultDto> query(CustomBusinessQueryDto dto) {
        return customBusinessMapper.query(dto);
    }

    @Override
    public Integer delete(CustomBusinessDeleteDto dto) {
        return customBusinessMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomBusinessResultDto> page(CustomBusinessQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomBusinessResultDto> result = (Page<CustomBusinessResultDto>) customBusinessMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomBusinessResultDto.class), page, result.getTotal());
    }
}
